<template>
  <div class="add-card">
    <header class="add-header">
      <el-page-header content="查看详情" @back="$router.back()" />
    </header>
    <main class="add-main">
      <div class="form-container">
        <div class="title">车辆信息</div>
        <div class="form">
          <el-descriptions>
            <el-descriptions-item label="车主信息">{{ tableData.personName }}</el-descriptions-item>
            <el-descriptions-item label="联系方式">{{ tableData.phoneNumber }}</el-descriptions-item>
          </el-descriptions>
          <el-descriptions>
            <el-descriptions-item label="车牌号码">{{ tableData.carNumber }}</el-descriptions-item>
            <el-descriptions-item label="车辆品牌">{{ tableData.carBrand }}</el-descriptions-item>
          </el-descriptions>
        </div>
      </div>
      <div class="form-container">
        <div class="title">月卡缴费记录</div>
        <el-table
          :data="rechargeList"
          style="width: 100%"
          height="200"
        >
          <el-table-column
            type="index"
            label="序号"
            width="100"
          />
          <el-table-column
            label="有效时间"
            width="200"
          >
            <template #default="{row}">
              {{ row.cardStartDate }} - {{ row.cardEndDate }}
            </template>
          </el-table-column>
          <el-table-column
            prop="paymentAmount"
            label="支付金额"
            width="150"
          />
          <el-table-column
            prop="paymentMethod"
            label="支付方式"
            width="150"
          />
          <el-table-column
            prop="createTime"
            label="办理时间"
            width="300"
          />
          <el-table-column
            prop="createUser"
            label="办理人"
            width="100"
          />
        </el-table>
      </div>
    </main>
  </div>
</template>

<script>
import { getCardDetailByIdAPI } from '@/api/card'

export default {
  data() {
    return {
      tableData: [],
      rechargeList: [],
      carForm: {
        personName: '',
        phoneNumber: '',
        carNumber: '',
        carBrand: ''
      }
    }
  },
  created() {
    this.getCardList()
  },
  methods: {
    async getCardList() {
      const { data: { carBrand, carInfoId, carNumber, personName, phoneNumber, rechargeList }} = await getCardDetailByIdAPI(this.$route.query.id)
      this.tableData = { carBrand, carInfoId, carNumber, personName, phoneNumber }
      this.rechargeList = rechargeList
    }
  }
}
</script>

  <style scoped lang="scss">
  .add-card {
    background-color: #f4f6f8;
    height: 100vh;

    .add-header {
      display: flex;
      align-items: center;
      padding: 0 20px;
      height: 64px;
      background-color: #fff;

      .left {
        span {
          margin-right: 4px;
        }
        .arrow{
          cursor: pointer;
        }
      }
    }

    .add-main {
      background: #f4f6f8;
      padding: 20px 130px;

      .form-container {
        background-color: #fff;

        .title {
          height: 60px;
          line-height: 60px;
          padding-left: 20px;
        }
        .el-table{
            margin-left: 100px;
        }

        .form {
          margin-bottom: 20px;
          padding: 20px 65px 24px;
          margin-left: 300px;
          .el-form {
            display: flex;
            flex-wrap: wrap;

            .el-form-item {
              width: 50%;
            }
          }
        }
      }
      .preview{
        img{
          width: 100px;
        }
      }
    }
  }
  </style>
